<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //数组去重
        var arr = [1, 2, 3, 1, 2, 4, 5, 3];
        var newArray = [];
        //遍历Arr
        for (var i = 0; i < arr.length; i++) {
            if (newArray.indexOf(arr[i]) == -1) {
                newArray.push(arr[i]);
            }
        }
        console.log(newArray);

        //二维数组
        var arr = [
            [1, 2, 3],
            [4, 5, 6],
            [3, 5]
        ];
        arr[0][1] = 100;
        delete arr[0][2];
        arr[0][4] = 900;
        console.log(arr);
        console.log(arr);

        var arr = [
            [1, 2, 3],
            [4, 5, 6],
            [3, 5]
        ];

        //遍历二维数组
        for (var i = 0; i < arr.length; i++) {
            for (var j = 0; j < arr[i].length; j++) {
                console.log(arr[i][j]);
            }
        }

        //关联数组:数组元素的下标为字符型
        //存储一个人的信息
        var person = [];
        person['name'] = 'Cai';
        person['age'] = 14;
        person['address'] = '北京市';
        console.log(person);
        console.log(person['name']);
        console.log(person['age']);


        //字符串对象
        //什么是字符串
        //由单引号包起来的0个或者多个字符如“hello” “”
        // 字符创对象的创建

        //创建一个空字符串对象
        var str = new String(); //表示创建一个空的字符串
        var str = new String('hello')
        console.log(str);
        console.log(typeof str); //Object


        //利用字面量形式创建
        var str = '';
        console.log(str);
        console.log(str.length);

        //字符串格式的获取

        //字符串只能获取不能增删改
        // 字符串一旦创建不能修改
        var str = 'hello';
        console.log(str[0]);
        console.log(str[1]);
        //字符串对象常用的属性
        var str = 'hello';
        console.log(str.length);
    </script>
</body>

</html>